/**
* @author Diego Gadola @ 29-01-09
*/
public class DiscussionWidgetActiveTopicController {

	private List<DiscussionTopic__c> activeTopics;
	private String id;
	
	/**
	* Constructor
	*/
	public DiscussionWidgetActiveTopicController() {
		id = System.currentPageReference().getParameters().get('id');
		findActiveTopics();
	}
	
	
	/**
	*@return List<DiscussionTopic__c>
	*/
	public List<DiscussionTopic__c> getActiveTopics() {
		return activeTopics;	
	}

	
	/**
	* Find active topics
	*/
	public void findActiveTopics() {
		if(id != null && id != '' && id.length() == 18) {
			activeTopics = [SELECT t.Subject__c, t.Id 
							FROM DiscussionTopic__c t
							WHERE t.DiscussionForum__c = :id
							ORDER BY t.MessageCount__c DESC NULLS LAST 
							LIMIT 5];
		} 
		else {
			activeTopics = new List<DiscussionTopic__c>();	
		}
	}
	
	
	/**
	*@return Integer
	*/
	public Integer getActiveTopicsSize() {
		return activeTopics.size();
	}

}